package com.xuchang.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xuchang.domain.SysMenu;
import com.xuchang.domain.SysPrivilege;
import com.xuchang.domain.SysRole;
import com.xuchang.domain.SysUserRole;
import com.xuchang.model.SysMenuPrivilegesDto;
import com.xuchang.service.SysMenuService;
import com.xuchang.mapper.SysMenuMapper;
import com.xuchang.service.SysPrivilegeService;
import com.xuchang.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author xuchang
 * @description 针对表【sys_menu(系统菜单)】的数据库操作Service实现
 * @createDate 2025-06-29 22:19:06
 */
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
    @Autowired
    private SysRoleService sysRoleService;
    @Autowired
    private SysMenuMapper sysMenuMapper;
    @Autowired
    private SysPrivilegeService sysPrivilegeService;

    @Override
    public List<SysMenu> getMenuByUserId(Long userId) {
        if (sysRoleService.isSuperAdmin(userId)) {
            return list(); // 查询所有
        }
        return sysMenuMapper.selectMenuByUserId(userId);
    }
}




